package com.ruslan.magaz.domain;
// default package
// Generated 28.09.2014 13:25:18 by Hibernate Tools 3.4.0.CR1

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.Digits;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

/**
 * Address generated by hbm2java
 */
@Entity
@Table(name = "address", catalog = "eshop")
public class Address implements java.io.Serializable {

	private int addressId;
	private Customer customer;
	@Size(min=2,max=50,message=	"Address1 must be between 2 and 50 characters long.")
	@Pattern(regexp="(?U)^\\w(\\w|[ \\-',\\.;_])*\\w$",	message="Illegal format")
	private String address1;
	@Size(min=2,max=50,message=	"Address2 must be between 2 and 50 characters long.")
	@Pattern(regexp="(?U)^\\w(\\w|[ \\-',\\.;_])*\\w$",	message="Illegal format")
	private String address2;
	@Size(min=2,max=15,message=	"City must be between 2 and 15 characters long.")
	@Pattern(regexp="(?U)^\\w(\\w|[ \\-'])*\\w$",	message="Illegal format")
	private String city;
	@Size(min=2,max=15,message=	"State must be between 2 and 15 characters long.")
	@Pattern(regexp="(?U)^\\w(\\w|[ \\-'])*\\w$",	message="Illegal format")
	private String state;
	@Size(min=2,max=15,message=	"Country must be between 2 and 15 characters long.")
	@Pattern(regexp="(?U)^\\w(\\w|[ \\-'])*\\w$",	message="Illegal format")
	private String country;
	@Digits(integer=10, fraction =0, message="Is it number?")
	private String zip;
	@Size(min=4,max=20,message=	"Wrong length!")
	@Pattern(regexp="(?U)^\\+?(\\d|[ \\-()])*\\d$",	message="Illegal format")
	private String phone;
	public Address() {
	}

	public Address(int addressId, Customer customer) {
		this.addressId = addressId;
		this.customer = customer;
	}

	public Address(int addressId, Customer customer, String address1,
			String address2, String city, String state, String country,
			String zip, String phone) {
		this.addressId = addressId;
		this.customer = customer;
		this.address1 = address1;
		this.address2 = address2;
		this.city = city;
		this.state = state;
		this.country = country;
		this.zip = zip;
		this.phone = phone;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "Address_id", unique = true, nullable = false)
	public int getAddressId() {
		return this.addressId;
	}

	public void setAddressId(int addressId) {
		this.addressId = addressId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "Customer_id", nullable = false)
	public Customer getCustomer() {
		return this.customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@Column(name = "Address1", length = 100)
	public String getAddress1() {
		return this.address1;
	}

	public void setAddress1(String address1) {
		this.address1 = address1;
	}

	@Column(name = "Address2", length = 100)
	public String getAddress2() {
		return this.address2;
	}

	public void setAddress2(String address2) {
		this.address2 = address2;
	}

	@Column(name = "City", length = 100)
	public String getCity() {
		return this.city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	@Column(name = "State", length = 100)
	public String getState() {
		return this.state;
	}

	public void setState(String state) {
		this.state = state;
	}

	@Column(name = "Country", length = 100)
	public String getCountry() {
		return this.country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	@Column(name = "ZIP", precision = 8, scale = 0)
	public String getZip() {
		return this.zip;
	}

	public void setZip(String zip) {
		this.zip = zip;
	}

	@Column(name = "Phone", precision = 8, scale = 0)
	public String getPhone() {
		return this.phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

}
